package com.design.facade;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

/**
 * @author leali
 * @title: FileWriter
 * @projectName design
 * @description: FileWriter：文件保存类，充当子系统类
 * @date 2022/1/3 0:05
 */
public class FileWriter {
    public void write(String encryptStr, String fileNameDst) {
        System.out.println("保存密文，写入文件");
        Path path = Paths.get(fileNameDst);
        try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8, StandardOpenOption.APPEND)) {
            writer.write(encryptStr);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
